//
//  TextOutlineUtil.m
//  Uang Pasti
//
//  Created by 李永彬 on 2025/8/22.
//

#import "TextOutlineUtil.h"

@implementation TextOutlineUtil

+ (NSAttributedString *)outlinedAttributedStringWithText:(NSString *)text
                                                    font:(UIFont *)font
                                               textColor:(UIColor *)textColor
                                            outlineColor:(UIColor *)outlineColor
                                             outlineWidth:(CGFloat)outlineWidth {
    if (!text || text.length == 0) return nil;
    
    // 创建可变属性字符串
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
    NSRange range = NSMakeRange(0, text.length);
    
    // 设置字体
    if (font) {
        [attributedString addAttribute:NSFontAttributeName value:font range:range];
    }
    
    // 设置文本颜色
    if (textColor) {
        [attributedString addAttribute:NSForegroundColorAttributeName value:textColor range:range];
    }
    
    // 添加描边属性
    [attributedString addAttribute:NSStrokeWidthAttributeName value:@(-outlineWidth) range:range];
    [attributedString addAttribute:NSStrokeColorAttributeName value:outlineColor range:range];
    
    return [attributedString copy];
}


@end
